package cn.bjc.basic.interceptor.config;

import cn.bjc.basic.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//相当于当前类是配置类    xml
@Configuration
public class MyConfig implements WebMvcConfigurer {
    
    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)//使用的拦截器
                .addPathPatterns("/**")//拦截路径
                .excludePathPatterns("/fastdfs/**")//放行路径
                .excludePathPatterns("/login/**")//放行路径
                .excludePathPatterns("/verifyCode/**")//放行路径
                .excludePathPatterns("/shop/settlement")//放行路径
                .excludePathPatterns("/shop/export")//放行路径
                .excludePathPatterns("/user/phoneRegister")//放行路径
                .excludePathPatterns("/user/emailRegister")//放行路径
                .excludePathPatterns("/swagger-resources/**", "/webjars/**",
                        "/v2/**", "/swagger-ui.html/**");//放行路径
    }
}
